package gold.digger;

import gold.utils.InputUtil;

import java.util.Arrays;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC942 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int[] diStringMatch(String s) {
            int[] ans = new int[s.length() + 1];
            int incNum = 0, descNum = s.length();
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'I') {
                    ans[i] = incNum++;
                } else {
                    ans[i] = descNum--;
                }
            }

            if (incNum == descNum) ans[s.length()] = incNum;
            return ans;
        }
    }

    public void run() {
        System.out.println(Arrays.toString(new Solution().diStringMatch("IDID")));
        System.out.println(Arrays.toString(new Solution().diStringMatch("III")));
        System.out.println(Arrays.toString(new Solution().diStringMatch("DDI")));
    }

    public static void main(String[] args) throws Exception {
        LC942 an = new LC942();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
